document.ready(function() {
    queryKey('ok');
});

function queryKey(flag) {
    openLoad();
    resetPageBar(flag);

    var param = {};
    param.ctrl = 'account';
    param.func = 'getRoleList';
    param.isuse = getAjaxValue('isuse');
    param.typeid = getAjaxValue('typeid');
    param.keyword = getAjaxValue('keyword');
    param.page = getAjaxValue('page');

    sendAjax(param, function(result) {
        roleList.list = result.roleList;

        loadPageBar(getValue('page'), result.allPages, result.rowCount);
        setHtml('listCount', result.listCount);

        setDisplay('mainBg', '');
        closeLoad();
    });
}

function addRole() {
    toUrl('admin.php?m=account&c=addRoleWeb');
}

function editRole(roleid) {
    toUrl('admin.php?m=account&c=editRoleWeb&roleid=' + roleid);
}

function deleteRole(roleid, name) {
    setValue('tempid', roleid);

    openConfirm('确定删除 【' + name + '】 吗？', tipleft, function() {
        var param = {};
        param.ctrl = 'account';
        param.func = 'deleteRole';
        param.roleid = getAjaxValue('tempid');

        sendAjax(param, function(result) {
            queryKey('page');
        });
    });
}

function setOperate(id, name) {
    openSlipIframeDiv('admin.php?m=account&c=operateSet&roleid=' + id + '&rolename=' + escape(name));
}